package com.bear.sgg.springboot_09_mybatis.controller;

import com.bear.sgg.springboot_09_mybatis.entity.Department;
import com.bear.sgg.springboot_09_mybatis.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import sun.awt.SunHints;

/**
 * @ClassNmae DepartmentController
 * @Description TODO
 * @Author bear
 * @Date 2020/3/15 0015 上午 11:19
 */
@RestController
public class DepartmentController {

    @Autowired
    DepartmentMapper departmentMapper;

    @GetMapping("/dept/{id}")
    public Department selectById(@PathVariable("id") Integer id) {
        return departmentMapper.selectById(id);
    }

    @GetMapping("/dept")
    public Department insertDept(Department department) {
        departmentMapper.insertDept(department);
        //由于配置了@Options注解，所以id值不会为空
        return department;
    }
}
